-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Gutenberg] Autosave #12489
[Gutenberg] Autosave #12489
Conversation
WordPress/Classes/ViewRelated/Gutenberg/GutenbergViewController.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and it works OK, however the behavior is different than it used to be. Previously, the debouncer logic would ensure that we autosaved at most once every 5 seconds. Now, it seems it will autosave after 2 seconds of inactivity.
I think the previous behavior was safer, as it ensured that if anything crashed you would lose at most 5 seconds of work. Now you could create a lot of content without pausing, and so without autosaving, and lose it all if the app crashes.
Also, let's keep in mind that the autosave logic in the web is meant to autosave to the server and AFAIK there's no local autosave concept (although it would be a nice feature addition 😉)
@etoledom : do we want this to target the (just created) |
Sounds good! Just did the change 👍 |
I see what you mean. We could always reduce the inactivity time to 1 second? I'd guess it's quite a lot less likely for someone to write a big piece of content without any one second of inactivity. @daniloercoli - what do you think? |
Yes, we can change it to 1 sec of inactivity, or even set a timer, or follow another logic we think is more appropriate for a mobile app with local storage. With this PR we're adding the autosaving to mobile-gb, before this PR nothing was autosaved, so I think there are room for improvement in another PR. |
We did have a timer on WPiOS requesting the current content to save it. That's the reason of @koke's comment here.
Is nice that we have that flexibility. I would say to merge this change on WPiOS as it is now to use the same mechanism as WPAndroid, and as @daniloercoli mentioned, keep improving it. 👍 What do you think @koke ? |
Autosave is now triggered after 50 continuous content changes or after 1 second of inactivity. This in both Aztec and Gutenberg.
/// - Parameter delay: Maximum time of inactivity before autosaving. Default 1 second. | ||
/// - Parameter action: The action to be triggered when autosave is fired. | ||
/// | ||
init(changesThreshold: Int = 50, delay: Double = 1, action: @escaping () -> Void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defaults are taken from WPAndroid.
Update: We have decided to implement a different approach for autosaving. This is to send content change events from Gutenberg, and let the native apps decide when is best to do an autosave. We also changed the logic to decide when is best to autosave:
This new autosave logic has been implemented in both Gutenberg and Aztec, matching the logic on WPAndroid. I have updated the initial PR description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working great @etoledom ! Excellent to see that you also changed Aztec editor and sharing the code between the two editors.
This PR implements the Gutenberg autosave mechanism replacing the previously implemented client-side autosave.
Update: The new logic implemented is described on #12489 (comment)
Updated Gutenberg PR: WordPress/gutenberg#17548
gutenberg-mobile
PR: Add "Autosave" bridge methods and enable local auto-save of posts gutenberg-mobile#1351gutenberg
PR: [RNMobile] Add autosave to mobile apps WordPress/gutenberg#17329WPAndroid
PR: Fix for local auto save that doesn't work in Gutenberg WordPress-Android#10483To test (updated):
gutenberg-mobile:develop
editorDidAutosave()
is invoked on every content change.debouncerCallback
is invoked after 1 second of inactivity.debouncerCallback
is invoked after typing 50 characters without break.Update release notes:
RELEASE-NOTES.txt
if necessary.